<template>
	<!-- 单选多选 -->
	<BaseField v-bind="props">
		<a-rate :size="size" style="font-size: 13px; min-height: auto" v-model="dataValue" @change="handleChange" :readonly="status === 'view'" />
	</BaseField>
</template>

<script setup lang="ts">
import { propsInfo } from "./utils/props";
import { isValid } from "@/utils";
const props = defineProps(propsInfo);
const emit = defineEmits(["update:modelValue", "update:fieldShow", "change"]);
const dataValue: any = ref(0);


const update = (data)=>{
	const info =  isValid(data) ? Number(data) : ""
	emit("update:modelValue", info);
	emit("update:fieldShow", info);
}

const handleChange = (info) => {
	update(info)
	emit("change", info);
};


watch(
	() => props.modelValue,
	(data) => {
		dataValue.value = isValid(data) ? Number(data) : 0;
		update(data)
	},
	{ immediate: true }
);
</script>

<style scoped></style>
